home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / mac / After Effects 3.1 SDK Mac / Examples / UI Samples / Custom UI in fx window / AEFX_FXwinUI.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-04  |  15.1 KB  |  675 lines  |  [TEXT/CWIE]

  1. /**
  2.     AEFX_FXwinUI.c
  3.     
  4.     Part of the Adobe After Effects 3.1 SDK    
  5.     Copyright (c)1993-96, Adobe Systems Inc, All Rights Reserved.
  6.  
  7.     Revision History
  8.         1.0, created by dmw
  9. **/
  10.  
  11. #include "AE_Effect.h"
  12. #include "AE_EffectCB.h"
  13. #include "AE_EffectUI.h"
  14.  
  15. #include "AEFX_FXwin.h"
  16. #include <math.h>
  17.  
  18.  
  19. Boolean CreateOffscreenBitMap (GWorldPtr *newOffscreen, short depth, Rect *inBounds)
  20. {
  21.     GWorldPtr    oldPort;
  22.     GDHandle    oldDev;
  23.     OSErr        err;
  24.     GWorldPtr    newWorld;
  25.  
  26.     GetGWorld(&oldPort, &oldDev);
  27.     
  28.     err = NewGWorld(&newWorld, depth, inBounds, NULL, NULL, 0);
  29.     if (!err) {
  30.         LockPixels(newWorld->portPixMap);
  31.         SetGWorld(newWorld, NULL);
  32.         EraseRect(inBounds);
  33.         UnlockPixels(newWorld->portPixMap);
  34.         *newOffscreen = newWorld;
  35.     } else {
  36.         *newOffscreen = NULL;
  37.     }
  38.     
  39.     SetGWorld(oldPort, oldDev);
  40.     if (err) return FALSE;
  41.     else return TRUE;
  42.     
  43. }  // CreateOffscreenBitMap
  44.  
  45.  
  46. void DestroyOffscreenBitMap( GWorldPtr oldOffscreen )
  47. {
  48.     DisposeGWorld((GWorldPtr)oldOffscreen);
  49.  
  50. }  // DestroyOffscreenBitMap
  51.  
  52.  
  53. static PolyHandle PolyFromParams (PF_ParamDef *params[])
  54. {
  55.     PolyHandle        temp;
  56.     long            min, max, soft_min, soft_max;
  57.     
  58.     min = params[EX_BLACK]->u.sd.value;
  59.     max = params[EX_WHITE]->u.sd.value;
  60.     soft_min = params[EX_BLACK_FUZ]->u.sd.value;
  61.     soft_max = params[EX_WHITE_FUZ]->u.sd.value;
  62.     
  63.     temp = OpenPoly();
  64.     if (temp) {
  65.         MoveTo(min - soft_min,  EX_WEDGE_HEIGHT - 2);
  66.         LineTo(min,  1);
  67.         LineTo(max - 1,  1);
  68.         LineTo(max + soft_max - 1 ,  EX_WEDGE_HEIGHT - 2);
  69.         LineTo(min - soft_min,  EX_WEDGE_HEIGHT - 2);
  70.         ClosePoly();
  71.     }
  72.     
  73.     return temp;
  74. }
  75.  
  76.  
  77. static PolyHandle PolyFromParamsInv (PF_ParamDef *params[], long which)
  78. {
  79.     PolyHandle        temp;
  80.     long            min, max, soft_min, soft_max;
  81.     
  82.     min = params[EX_BLACK]->u.sd.value;
  83.     max = params[EX_WHITE]->u.sd.value;
  84.     soft_min = params[EX_BLACK_FUZ]->u.sd.value;
  85.     soft_max = params[EX_WHITE_FUZ]->u.sd.value;
  86.     
  87.     temp = OpenPoly();
  88.     if (temp && which) {
  89.         MoveTo (0, 1);
  90.         LineTo(min, 1);
  91.         LineTo(min - soft_min, EX_WEDGE_HEIGHT - 2);
  92.         LineTo(0, EX_WEDGE_HEIGHT - 2);
  93.         LineTo(0, 1);
  94.         ClosePoly();
  95.  
  96.     } else if (temp) {
  97.         MoveTo(255, 1);
  98.         LineTo(255, EX_WEDGE_HEIGHT - 2);
  99.         LineTo(max + soft_max, EX_WEDGE_HEIGHT - 2);
  100.         LineTo(max, 1);
  101.         LineTo(255, 1);
  102.         ClosePoly();
  103.     }
  104.     
  105.     return temp;
  106. }
  107.  
  108.  
  109. static PF_Err DrawHist (
  110.             PF_ParamDef        *params[],
  111.             EX_Globals        *globals )
  112. {
  113.     PF_Err        err = PF_Err_NONE;
  114.     GWorldPtr        saveWorld;
  115.     GDHandle        saveDevice;
  116.     GWorldPtr        offscreen = globals->graphbits;
  117.     long            y;
  118.     long            max_hist;
  119.     long            *histogram;
  120.     long            scale_hist[256];
  121.     double            scale;
  122.     
  123.     histogram = globals->hist;
  124.     max_hist = globals->hist[0];
  125.  
  126.     for (y=0; y<256; y++) {
  127.         if (histogram[y] > max_hist) max_hist = histogram[y];            
  128.     }
  129.     
  130.     scale = ((double)EX_HIST_HEIGHT/(double)max_hist);
  131.     
  132.     for (y=0; y<256; y++) {
  133.         scale_hist[y] = scale * histogram[y];
  134.     }
  135.     
  136.  
  137.     GetGWorld(&saveWorld, &saveDevice);
  138.     SetGWorld(offscreen, NULL);
  139.     
  140.     EraseRect(&globals->offRect);
  141.     if (globals->freshHist) {
  142.         for (y=0; y<256; y++) {
  143.             MoveTo(y, EX_HIST_HEIGHT);
  144.             LineTo(y, EX_HIST_HEIGHT-scale_hist[y]);
  145.         }
  146.     } else {
  147.         MoveTo(0, 0);
  148.         LineTo(EX_HIST_WIDTH, EX_HIST_HEIGHT);
  149.         
  150.         MoveTo(0, EX_HIST_HEIGHT);
  151.         LineTo(EX_HIST_WIDTH, 0);
  152.         FrameRect(&globals->offRect);
  153.     }
  154.  
  155.     SetGWorld(saveWorld, saveDevice);
  156.  
  157.     return err;
  158. }
  159.  
  160.  
  161. static void GetHandleBox (
  162.                 long            which,
  163.                 PF_ParamDef        *params[],
  164.                 Rect            *box )
  165. {
  166.     long            min, max, soft_min, soft_max;
  167.  
  168.     long            hi, lo;
  169.     
  170.     min = params[EX_BLACK]->u.sd.value;
  171.     max = params[EX_WHITE]->u.sd.value;
  172.     soft_min = params[EX_BLACK_FUZ]->u.sd.value;
  173.     soft_max = params[EX_WHITE_FUZ]->u.sd.value;
  174.  
  175.     SetRect(box, -2, -2, 2, 2);
  176.     
  177.     if (FALSE && params[EX_INVERT]->u.pd.value) {
  178.         lo = EX_WEDGE_HEIGHT - 2;
  179.         hi = 1;
  180.     } else {
  181.         hi = EX_WEDGE_HEIGHT - 2;
  182.         lo = 1;
  183.     }    
  184.  
  185.     switch (which) {
  186.         case 2:
  187.             OffsetRect(box, min - soft_min, hi);
  188.             break;
  189.             
  190.         case 3:
  191.             OffsetRect(box, max + soft_max - 1 ,  hi);
  192.             break;
  193.         
  194.         case 0:
  195.             OffsetRect(box, min,  lo);
  196.             break;
  197.             
  198.         case 1:
  199.             OffsetRect(box, max - 1,  lo);
  200.             break;
  201.     }
  202. }
  203.  
  204.  
  205. static PF_Err DrawPoly (
  206.             PF_InData        *in_data,
  207.             PF_ParamDef        *params[],
  208.             EX_Globals        *globals )
  209. {
  210.     PF_Err            err = PF_Err_NONE;
  211.     PolyHandle        poly;
  212.     Rect            box;
  213.     GWorldPtr        saveWorld;
  214.     GDHandle        saveDevice;
  215.     GWorldPtr        offscreen = globals->wedgebits;
  216.     long            i;
  217.     
  218.     GetGWorld(&saveWorld, &saveDevice);
  219.     SetGWorld(offscreen, NULL);
  220.     
  221.     EraseRect(&globals->wedgeRect);
  222.     if (params[EX_INVERT]->u.pd.value) {
  223.         poly = PolyFromParamsInv(params, 1);
  224.         FillPoly(poly, &in_data->qd_globals->gray);
  225.         FramePoly(poly);
  226.         KillPoly(poly);
  227.     
  228.         poly = PolyFromParamsInv(params, 0);
  229.         FillPoly(poly, &in_data->qd_globals->gray);
  230.         FramePoly(poly);
  231.         KillPoly(poly);
  232.     
  233.     } else {
  234.         poly = PolyFromParams(params);
  235.         FillPoly(poly, &in_data->qd_globals->gray);
  236.         FramePoly(poly);
  237.         KillPoly(poly);
  238.     }
  239.  
  240.     // ltrb
  241.     
  242.     for (i=0; i<4; i++) {
  243.         GetHandleBox(i, params, &box);
  244.         InvertRect(&box);
  245.     }
  246.     
  247.     SetGWorld(saveWorld, saveDevice);
  248.     return err;
  249.     
  250. }
  251.  
  252.  
  253. static void GetWedgeBlitRect (
  254.                      PF_ParamDef        *params[],
  255.                     PF_EventExtra    *event_extra,
  256.                     Rect            *wedge )
  257. {
  258.     *wedge = event_extra->effect_win.current_frame;
  259.     wedge->right = wedge->left + EX_HIST_WIDTH;
  260.     wedge->top += EX_HIST_HEIGHT + 10;
  261.     wedge->bottom = wedge->top + EX_WEDGE_HEIGHT;
  262. }
  263.  
  264.  
  265. static void GetWedgeHitRect (
  266.                      PF_ParamDef        *params[],
  267.                     PF_EventExtra    *event_extra,
  268.                     Rect            *wedge )
  269. {
  270.     short        left_in, right_in;
  271.     
  272.     left_in = params[EX_BLACK]->u.sd.value - params[EX_BLACK_FUZ]->u.sd.value;
  273.     if (left_in < 0) left_in = 0; else if (left_in > 255) left_in = 255;
  274.     
  275.     right_in = params[EX_WHITE]->u.sd.value + params[EX_WHITE_FUZ]->u.sd.value;
  276.  
  277.     right_in = 255 - right_in;
  278.     
  279.     if (right_in < 0) right_in = 0; else if (right_in > 255) right_in = 255;
  280.     GetWedgeBlitRect(params, event_extra, wedge);
  281.  
  282.     wedge->left += left_in;
  283.     wedge->right -= right_in;
  284. }
  285.  
  286. static PF_Err DrawEvent (
  287.             PF_InData        *in_data,
  288.             PF_OutData        *out_data,
  289.             PF_ParamDef        *params[],
  290.             PF_LayerDef        *output,
  291.             PF_EventExtra    *event_extra,
  292.             Boolean            erase )
  293. {
  294.     PF_Err            err = PF_Err_NONE;
  295.     EX_Globals         **globH;
  296.     EX_Globals         *globP;
  297.     Rect            offscreen, preview, cur_frame;
  298.     GrafPtr            dp = (*(event_extra->contextH))->cgrafptr;
  299.     GWorldPtr        saveWorld;
  300.     GDHandle        saveDevice;
  301.     PixMapHandle    pixBase;
  302.     Rect            er_rect;
  303.     
  304.     // stuff params into globals -- we need amount & type
  305.  
  306.     if ((*event_extra->contextH)->w_type == PF_Window_EFFECT) {
  307.         if (event_extra->effect_win.area == PF_EA_CONTROL) {
  308.             
  309.             cur_frame = event_extra->effect_win.current_frame;
  310.             if (erase) EraseRect(&cur_frame);
  311.             GetGWorld(&saveWorld, &saveDevice);
  312.             
  313.             globH = (EX_Globals **)in_data->sequence_data;
  314.             globP = *(globH);
  315.             offscreen = globP->offRect;
  316.  
  317.             preview.top = event_extra->effect_win.current_frame.top;
  318.             preview.left = event_extra->effect_win.current_frame.left;
  319.             preview.right = preview.left + EX_HIST_WIDTH;
  320.             preview.bottom = preview.top + EX_HIST_HEIGHT;
  321.             
  322. //            ltrb
  323.  
  324.             DrawHist(params, globP);
  325.             
  326.             DrawPoly(in_data, params, globP);
  327.             
  328.             if (globP->magic == EX_MAGIC) {
  329.                 pixBase = GetGWorldPixMap(globP->graphbits);
  330.                 if (LockPixels(pixBase)) {
  331.                     er_rect = cur_frame;
  332.                     er_rect.left = preview.right;
  333.                     er_rect.bottom = preview.bottom;
  334.                     EraseRect(&er_rect);
  335.                     CopyBits((BitMap*)*pixBase, &dp->portBits,
  336.                      &offscreen, &preview, srcCopy, 0L);
  337.  
  338.                     UnlockPixels(pixBase);
  339.                 }
  340.  
  341.                 pixBase = GetGWorldPixMap(globP->wedgebits);
  342.                 if (LockPixels(pixBase)) {
  343.                     er_rect = cur_frame;
  344.                     er_rect.left = preview.right;
  345.                     er_rect.bottom = preview.bottom;
  346.                     offscreen = globP->wedgeRect;
  347.                     EraseRect(&er_rect);
  348.                     
  349.                     GetWedgeBlitRect(params, event_extra, &preview);
  350.                     
  351.                     CopyBits((BitMap*)*pixBase, &dp->portBits,
  352.                      &offscreen, &preview, srcCopy, 0L);
  353.  
  354.                     UnlockPixels(pixBase);
  355.                 }
  356.  
  357.             } else {
  358.                 out_data->out_flags |= PF_OutFlag_DISPLAY_ERROR_MESSAGE;
  359.                 PF_SPRINTF(out_data->return_msg, "Magic failed in Draw Event.");
  360.                 err = PF_Err_BAD_CALLBACK_PARAM;
  361.             }
  362.             
  363.             SetGWorld(saveWorld, saveDevice);
  364.         }
  365.     }
  366.     
  367.     return err;
  368. }
  369.  
  370.  
  371. static PF_Err NewContext (
  372.             PF_InData        *in_data,
  373.             PF_OutData        *out_data,
  374.             PF_ParamDef        *params[],
  375.             PF_LayerDef        *output,
  376.             PF_EventExtra    *event_extra )
  377. {
  378.     PF_Err        err = PF_Err_NONE;
  379.  
  380.     return err;
  381. }
  382.  
  383.  
  384. static PF_Err MyInfoReport (
  385.                  PF_EventExtra        *event_extra,
  386.                 char                *str1,
  387.                 char                *str2 )
  388. {
  389.     PF_Err                    err = PF_Err_NONE;
  390.     GWorldPtr                saveWorld;
  391.     GDHandle                saveDevice;
  392.  
  393.     PF_Err                    (*infotext)(void *refcon, char *text1, char *text2);
  394.     void                    *refcon;
  395.     
  396.     refcon = event_extra->cbs.refcon;
  397.     infotext = event_extra->cbs.info_draw_text;
  398.  
  399.     GetGWorld(&saveWorld, &saveDevice);
  400.     
  401.     (*infotext)(refcon, str1, str2);
  402.     
  403.     SetGWorld(saveWorld, saveDevice);
  404.     
  405.     return err;
  406. }    
  407.  
  408.  
  409. static Boolean DoClickWedge (
  410.                 PF_InData        *in_data,
  411.                 PF_OutData        *out_data,
  412.                 PF_ParamDef        *params[],
  413.                 PF_LayerDef        *output,
  414.                 PF_EventExtra    *event_extra )
  415. {
  416.     Rect                    wedge_hit;
  417.     Point                    click_pt;
  418.     Boolean                    did_click = FALSE;
  419.     
  420.     GetWedgeHitRect(params, event_extra, &wedge_hit);
  421.     click_pt = event_extra->u.do_click.screen_point;
  422.     
  423.     if (PtInRect(click_pt, &wedge_hit)) {
  424.         did_click = TRUE;
  425.         event_extra->u.do_click.send_drag = TRUE;
  426.         event_extra->u.do_click.continue_refcon[0] = EX_Drag_WEDGE;
  427.         event_extra->u.do_click.continue_refcon[1] = click_pt.h;
  428.         event_extra->u.do_click.continue_refcon[2] = params[EX_BLACK]->u.sd.value;
  429.         event_extra->u.do_click.continue_refcon[3] = params[EX_WHITE]->u.sd.value;
  430.     }
  431.  
  432.     return did_click;    
  433. }
  434.  
  435.  
  436. static void DoDragWedge (
  437.                 PF_InData        *in_data,
  438.                 PF_OutData        *out_data,
  439.                 PF_ParamDef        *params[],
  440.                 PF_LayerDef        *output,
  441.                 PF_EventExtra    *event_extra )
  442. {
  443.     Point                    click_pt;
  444.     short                    dx;
  445.     long                    black, white;
  446.     
  447.     click_pt = event_extra->u.do_click.screen_point;
  448.     dx = click_pt.h - event_extra->u.do_click.continue_refcon[1];
  449.  
  450.     event_extra->u.do_click.continue_refcon[1] = click_pt.h;
  451.                         
  452.      event_extra->u.do_click.continue_refcon[2] += dx;
  453.     event_extra->u.do_click.continue_refcon[3] += dx;
  454.       
  455.       black = event_extra->u.do_click.continue_refcon[2];
  456.       white = event_extra->u.do_click.continue_refcon[3];
  457.       
  458.       if (black < 0) {
  459.           params[EX_BLACK]->u.sd.value = 0;
  460.           params[EX_WHITE]->u.sd.value = white - black;
  461.       } else if (white > 255) {
  462.           params[EX_BLACK]->u.sd.value = 255 - white + black;
  463.           params[EX_WHITE]->u.sd.value = 255;
  464.       } else {
  465.         params[EX_BLACK]->u.sd.value = black;
  466.         params[EX_WHITE]->u.sd.value = white;
  467.     }
  468.     DrawEvent(in_data, out_data, params, output, event_extra, FALSE);
  469.     params[EX_BLACK]->changed = TRUE;
  470.     params[EX_WHITE]->changed = TRUE;
  471.  
  472.     event_extra->evt_out_flags |= PF_EO_HANDLED_EVENT;
  473. }
  474.  
  475.  
  476. static Boolean DoClickHandles (
  477.                 PF_InData        *in_data,
  478.                 PF_OutData        *out_data,
  479.                 PF_ParamDef        *params[],
  480.                 PF_LayerDef        *output,
  481.                 PF_EventExtra    *event_extra )
  482. {
  483.     Rect                    box_hit;
  484.     Rect                    preview;
  485.     Point                    click_pt, old_pt, mouse_pt;
  486.     short                    dx_orig, dx_last;
  487.     Boolean                    did_click = FALSE;
  488.     long                    i;
  489.     long                    orig_value;
  490.  
  491.     GetWedgeBlitRect(params, event_extra, &preview);
  492.     
  493.     for (i=0; i<4; i++) {
  494.         GetHandleBox(i, params, &box_hit);
  495.         OffsetRect(&box_hit, preview.left, preview.top);
  496.         InsetRect(&box_hit, -2, -2);
  497.         click_pt = old_pt = event_extra->u.do_click.screen_point;
  498.         
  499.         if (PtInRect(click_pt, &box_hit)) {
  500.             orig_value = params[EX_BLACK + i]->u.sd.value;
  501.             
  502.             while (StillDown()) {
  503.                 GetMouse(&mouse_pt);
  504.                 dx_orig = mouse_pt.h - click_pt.h;
  505.                 if (mouse_pt.h < 0 || mouse_pt.h > (260 + event_extra->effect_win.current_frame.left)) {
  506.                     dx_last = 0;
  507.                 } else {
  508.                     dx_last = mouse_pt.h - old_pt.h;
  509.                 }
  510.                             
  511.                 if (dx_last) {
  512.                     switch (i) {
  513.                           case 0:                // ex_black
  514.                               if ((dx_orig + orig_value) < 0) {
  515.                                   params[EX_BLACK]->u.sd.value = 0;
  516.                               } else if ((dx_orig + orig_value) >= params[EX_WHITE]->u.sd.value) {
  517.                                   params[EX_BLACK]->u.sd.value = params[EX_WHITE]->u.sd.value - 1;
  518.                               } else {
  519.                                   params[EX_BLACK]->u.sd.value = dx_orig + orig_value;
  520.                               }
  521.                               
  522.                               break;
  523.                               
  524.                           case 1:                // ex_white
  525.                               if ((dx_orig + orig_value) > 255) {
  526.                                   params[EX_WHITE]->u.sd.value = 255;
  527.                               } else if ((dx_orig + orig_value) <= params[EX_BLACK]->u.sd.value) {
  528.                                   params[EX_WHITE]->u.sd.value = params[EX_BLACK]->u.sd.value + 1;
  529.                               } else {
  530.                                   params[EX_WHITE]->u.sd.value = dx_orig + orig_value;
  531.                               }
  532.                               
  533.                               break;
  534.                               
  535.                           case 2:                // black soft
  536.                               dx_orig = -dx_orig;
  537.                               if ((dx_orig + orig_value) < 0) {
  538.                                   params[EX_BLACK_FUZ]->u.sd.value = 0;
  539.                               } else {
  540.                                   params[EX_BLACK_FUZ]->u.sd.value = dx_orig + orig_value;
  541.                               }
  542.                               
  543.                               break;
  544.                               
  545.                           case 3:                // white soft
  546.                               if ((dx_orig + orig_value) < 0) {
  547.                                   params[EX_WHITE_FUZ]->u.sd.value = 0;
  548.                               } else {
  549.                                   params[EX_WHITE_FUZ]->u.sd.value = dx_orig + orig_value;
  550.                               }
  551.                               break;    
  552.                     }
  553.                 }
  554.                 params[i + EX_BLACK]->changed = TRUE;
  555.                 
  556.                 
  557.                 DrawEvent(in_data, out_data, params, output, event_extra, FALSE);
  558.                 did_click = TRUE;
  559.                 old_pt = mouse_pt;
  560.             }
  561.         }
  562.         if (did_click) break;
  563.     }
  564.  
  565.     return did_click;    
  566. }
  567.  
  568.  
  569. static PF_Err DoClick (
  570.             PF_InData        *in_data,
  571.             PF_OutData        *out_data,
  572.             PF_ParamDef        *params[],
  573.             PF_LayerDef        *output,
  574.             PF_EventExtra    *event_extra )
  575. {
  576.     PF_Err                     err = PF_Err_NONE;
  577.     PF_ContextH                contextH = event_extra->contextH;
  578.  
  579.     if ((*contextH)->w_type == PF_Window_EFFECT) {
  580.         
  581.         if (event_extra->effect_win.area == PF_EA_CONTROL) {
  582.         
  583.             if (DoClickHandles(in_data, out_data, params, output, event_extra)) {
  584.                 event_extra->evt_out_flags |= PF_EO_HANDLED_EVENT;
  585.             } else if (DoClickWedge(in_data, out_data, params, output, event_extra)) {
  586.                 event_extra->evt_out_flags |= PF_EO_HANDLED_EVENT;
  587.             }
  588.  
  589.         }        
  590.         
  591.     }
  592.     
  593.     return err;
  594. }
  595.  
  596.  
  597. static PF_Err DoDrag (
  598.             PF_InData        *in_data,
  599.             PF_OutData        *out_data,
  600.             PF_ParamDef        *params[],
  601.             PF_LayerDef        *output,
  602.             PF_EventExtra    *event_extra )
  603. {
  604.     PF_Err                     err = PF_Err_NONE;
  605.     PF_ContextH                contextH = event_extra->contextH;
  606.  
  607.     if ((*contextH)->w_type == PF_Window_EFFECT) {
  608.         
  609.         if (event_extra->effect_win.area == PF_EA_CONTROL) {
  610.             if (event_extra->u.do_click.continue_refcon[0] == EX_Drag_WEDGE)
  611.                 DoDragWedge(in_data, out_data, params, output, event_extra);
  612.         }        
  613.     }
  614.     
  615.     return err;
  616. }
  617.  
  618.  
  619. PF_Err HandleEvent (
  620.     PF_InData        *in_data,
  621.     PF_OutData        *out_data,
  622.     PF_ParamDef        *params[],
  623.     PF_LayerDef        *output,
  624.     PF_EventExtra    *event_extra )
  625. {
  626.     PF_Err        err = PF_Err_NONE;
  627.  
  628.     if (in_data->sequence_data == NULL &&
  629.          (event_extra->e_type == PF_Event_DO_CLICK ||
  630.           event_extra->e_type == PF_Event_DRAW)) {
  631.         err = SequenceResetup(in_data, out_data, params, output);
  632.         if (!err) in_data->sequence_data = out_data->sequence_data;
  633.     }
  634.  
  635.     switch (event_extra->e_type) {
  636.  
  637.         case PF_Event_NEW_CONTEXT:
  638.             NewContext(in_data, out_data, params, output, event_extra);
  639.             break;
  640.             
  641.         case PF_Event_ACTIVATE:
  642.             break;
  643.         
  644.         case PF_Event_DO_CLICK:
  645.             DoClick(in_data, out_data, params, output, event_extra);
  646.             break;
  647.         
  648.         case PF_Event_DRAG:
  649.             // right now, drag events are only sent for the wedge -> need to support drag for 
  650.             // the other handles
  651.             
  652.             DoDrag(in_data, out_data, params, output, event_extra);
  653.             break;
  654.         
  655.         case PF_Event_DRAW:
  656.             DrawEvent(in_data, out_data, params, output, event_extra, TRUE);
  657.             break;
  658.         
  659.         case PF_Event_DEACTIVATE:
  660.             break;
  661.         
  662.         case PF_Event_CLOSE_CONTEXT:
  663.             break;
  664.         
  665.         case PF_Event_IDLE:
  666.             break;
  667.         
  668.         default:
  669.             break;
  670.         
  671.     }
  672.     
  673.     return err;
  674. }
  675.